import entity.Account;
import entity.CreateAccountDTO;
import entity.CreateAccountVO;
import entity.User;
import utils.AccountConvertUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author tanghailan
 * @date 2022-01-18 16:10:26
 * @description
 */
public class MapStructTest {
  public static void main(String[] args) {
    CreateAccountDTO createAccountDTO = new CreateAccountDTO();
    List<Account> accounts = new ArrayList<>();
    accounts.add(new Account("ACT2021051200000001", 1000));
    accounts.add(new Account("ACT2021051200000002", 5000));
    createAccountDTO.setKey("326D1478E3914C8A");
    createAccountDTO.setAccounts(accounts);

    User user = new User("Jaemon", Arrays.asList("SZ", "NS"));

    // 执行1
    //        CreateAccountVO createAccountVO =
    // AccountConvertUtils.INSTANCE.convert(createAccountDTO);
    // 执行2
    //        CreateAccountVO createAccountVO =
    // AccountConvertUtils.INSTANCE.convertWithMapping(createAccountDTO);
    // 执行3
    CreateAccountVO createAccountVO = AccountConvertUtils.INSTANCE.convert(user, createAccountDTO);

    createAccountDTO.getAccounts().add(new Account("ACT2021051200000003", 1010));

    //    System.out.println(createAccountDTO.toString());
    //    System.out.println(createAccountVO.toString());
    List<Account> list = new ArrayList<>();
    list.add(new Account("ACT2021051200000001", 1000));
    list.add(new Account("ACT2021051200000002", 2000));
    List<Account> copy = AccountConvertUtils.INSTANCE.copy(list);
    list.add(new Account("ACT2021051200000003", 3000));
    copy.forEach(System.out::println);
    System.out.println("----------------");
    list.forEach(System.out::println);
  }
}
